package com.sanda.bailin.restcontroller;

import com.sanda.bailin.pojo.BaseResponse;
import com.sanda.bailin.pojo.UserInfo;
import com.sanda.bailin.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class HelloRestController {
    @Autowired
    HelloService helloService;

    @RequestMapping("/get_user_info")
    BaseResponse<List<UserInfo>> getUserInfo(Integer page,Integer limit){
        Integer offset = Math.max((page-1)*limit,0);
        List<UserInfo> userInfo = helloService.getUserInfo(limit,offset);
        Integer count = helloService.getCount();
        return BaseResponse.success(userInfo,count);
    }
}
